<?php

$num_columns  = 3;
$can_delete = $this->auth->has_permission('Area.Content.Delete');
$can_edit   = $this->auth->has_permission('Area.Content.Edit');
$has_records  = isset($records) && is_array($records) && count($records);

if ($can_delete) {
    $num_columns++;
}
?>

<section class="content-header">
  <h1>
    <?php echo lang('area_area_title'); ?>管理
    <!-- <small>advanced tables</small> -->
  </h1>
  <!-- <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="#">Tables</a></li>
    <li class="active">Data tables</li>
  </ol> -->
</section>

<!-- Main content -->
<section class="content">
  <div class="row">
    <div class="col-xs-12">

      <div class="nav-tabs-custom">
      <div class="box-tools pull-right" style="top: 5px;display: block;position: relative;right: 20px;">
                <!-- <div class="pull-right" style="margin-bottom:20px;margin-top: 5px;"> -->
                  
                <!--  <a href="/<?php echo SITE_AREA . '/content/area/create'; ?>"  class="btn btn-block btn-primary">新增</a> -->
                <!-- </div> -->
          </div>

            <ul class="nav nav-tabs">
              <li<?php echo $filter_type == 'active' ? ' class="active"' : ''; ?>><?php echo anchor("{$index_url}active/", '已开通的城市'); ?><!-- <a href="#activity" data-toggle="tab">已开通的城市</a> --></li>
              <li<?php echo $filter_type == 'all' ? ' class="active"' : ''; ?>><?php echo anchor("{$index_url}all/", '全部城市'); ?><!-- <a href="#timeline" data-toggle="tab">全部城市</a> --></li>
            </ul>
            <div class="tab-content">

      <!-- <div class="box box-primary"> -->
      <?php echo form_open($this->uri->uri_string()); ?>
        <div class="box-header">
          <h3 class="box-title"><?php echo lang('area_area_title'); ?></h3>
          
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <table id="example2" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
            <?php if ($can_delete) : ?>
              <th class='column-check'><input class='check-all' type='checkbox' /></th>
            <?php endif;?>
              <th>ID</th>
              <th>父级</th>
              <th>名称</th>
              <th>城市编号</th>
              <th>操作</th>
            </tr>
            </thead>
            <tbody>
              <?php
        if ($has_records) :
          foreach ($records as $record) :
        ?>
        <tr>
          <?php if ($can_delete) : ?>
          <td class='column-check'><input type='checkbox' name='checked[]' value='<?php echo $record->area_id; ?>' /></td>
          <?php endif;?>

          <td><?php e($record->area_id); ?></td>
          <td><?php e($record->parent_name); ?></td>
          <td><?php e($record->area_name); ?></td>
          <td><?php e($record->code); ?></td>

          <?php if ($can_edit) : ?>
            <td><a href="/<?php echo SITE_AREA . '/content/area/edit/' . $record->area_id; ?>" class="btn btn-xs btn-primary"><i class="fa fa-pencil" data-toggle="tooltip" data-placement="top" title="" data-original-title="Edit"></i></a>

            
            <a href="/<?php echo SITE_AREA . '/content/area/delete/' . $record->area_id; ?>" class="btn btn-xs btn-danger" style="cursor:pointer;" onclick="return confirm('确定删除吗?');"><i class="fa fa-trash" data-toggle="tooltip" data-placement="top" title="" data-original-title="Delete"></i></a>

            </td>
           <?php else : ?>
            <td></td>
          <?php endif; ?>
        </tr>
        <?php
          endforeach;
        else:
        ?>
        <tr>
          <td colspan='<?php echo $num_columns; ?>'><?php echo lang('area_records_empty'); ?></td>
        </tr>
        <?php endif; ?>
          </table>
        </div>
        <!-- /.box-body -->
        
      <div class="box-footer">
        <div class="pull-left">
          选择之后：
          <button type="submit" name='delete' class="btn btn-danger" onclick="return confirm('确定删除吗?');"><?php echo lang('bf_action_delete'); ?></button>
          </div>
          <div class="pull-right">
            <?php echo $this->pagination->create_links(); ?>
          </div>
          </div>
        <?php
        echo form_close();
          // echo $this->pagination->create_links(); 
      ?>
      <!-- </div> -->
      </div></div>
      <!-- /.box -->
    </div>
    <!-- /.col -->
  </div>

</section>
